package com.example.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.util.Date;
import java.math.BigInteger;

/**
 * Gas价格表
 */
@Data
@TableName(value = "tb_gas_price", autoResultMap = true)
public class GasPrice {
    public void setId(Long id) {
        this.id = id;
    }
    public Long getId() {
        return id;
    }

    @TableId(type = IdType.AUTO)
    private Long id;

    /** 当前标准Gas价格（Wei） */
    private Long baseGasPrice;

    /** 1.2x Gas价格（Wei） */
    private Long gasPrice12x;

    /** 1.5x Gas价格（Wei） */
    private Long gasPrice15x;

    /** 采集时区块号 */
    private Long blockNumber;

    /** 更新时间 */
    private Date updateTime;

    /**
     * 兼容GasPriceService，设置标准Gas价格（Wei）
     */
    public void setBaseGasPrice(BigInteger gasPriceWei) {
        if (gasPriceWei != null) {
            this.baseGasPrice = gasPriceWei.longValue();
            this.gasPrice12x = (long) (gasPriceWei.longValue() * 1.2);
            this.gasPrice15x = (long) (gasPriceWei.longValue() * 1.5);
        }
    }

    public BigInteger getBaseGasPrice() {
        return baseGasPrice == null ? null : BigInteger.valueOf(baseGasPrice);
    }

    /**
     * 兼容GasPriceService，设置采集/同步时间
     */
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    public Date getUpdateTime() {
        return this.updateTime;
    }

}
